package com.avic.rong.course.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.avic.rong.R;
import com.avic.rong.activity.login.LoginPhoneActivity;
import com.avic.rong.course.bean.CompanysBean;
import com.avic.rong.questionOrAnswer.activity.PersonalHomeActivity;
import com.avic.rong.utils.DensityUtils;
import com.avic.rong.utils.SharedPreferencesUtil;
import com.avic.rong.utils.StringUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.coorchice.library.SuperTextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Chenjiaxin on 2019/8/11 18:19
 * E-Mail Address：16601203965@163.com
 */
public class PublishAdapter extends RecyclerView.Adapter<PublishAdapter.PublishViewHolder> {

    private Context context;
    private LayoutInflater inflater;

    private String[] title;
    private String[] company;
    private int[] icon;

    public PublishAdapter(Context context) {
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    public void setDataList(String[] title, String[] company, int[] icon) {
        this.title = title;
        this.company = company;
        this.icon = icon;
        notifyDataSetChanged();
    }


    @NonNull
    @Override
    public PublishViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = inflater.inflate(R.layout.publish_rv_item, viewGroup, false);
        return new PublishViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull PublishViewHolder holder, int position) {
        holder.tv_name.setText(title[position]);
        holder.tv_company_name.setText(company[position]);
        holder.img_header.setImageResource(icon[position]);
    }

    @Override
    public int getItemCount() {
        return title == null ? 0 : title.length;
    }


    public class PublishViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_company_name)
        TextView tv_company_name;
        @BindView(R.id.img_header)
        ImageView img_header;

        public PublishViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
